package com.gqb.wangyi;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class theLastChar {
	private static BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args) throws NumberFormatException, IOException {
		int line=Integer.parseInt(in.readLine().toString());
		for (int i = 0; i < line; i++) {
			String str=in.readLine();
			System.out.println(getFirstOnly(str));
		}
	}
	
	public static Character getFirstOnly(String str){
		char[] c=str.toCharArray();
		for (int i = 0; i < c.length; i++) {
			if(str.indexOf(c[i])==str.lastIndexOf(c[i])){
				return c[i];
			}
		}
		return ' ';
	}
 
}
